package com.shitou.shitouwarehouse.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.shitou.shitouwarehouse.entity.ShAreaEntity;
import com.shitou.shitouwarehouse.service.ShAreaService;
import com.shitou.shitoucommons.utils.PageUtils;
import com.shitou.shitoucommons.utils.RespBean;



/**
 * 全国省市区信息
 *
 * @author 石头人
 * @email 3076767823@qq.com
 * @date 2023-03-13 12:47:55
 */
@RestController
@RequestMapping("shitouwarehouse/sharea")
public class ShAreaController {
    @Autowired
    private ShAreaService shAreaService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public RespBean list(@RequestParam Map<String, Object> params){
        PageUtils page = shAreaService.queryPage(params);

        return RespBean.success().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public RespBean info(@PathVariable("id") Integer id){
		ShAreaEntity shArea = shAreaService.getById(id);

        return RespBean.success().put("shArea", shArea);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public RespBean save(@RequestBody ShAreaEntity shArea){
		shAreaService.save(shArea);

        return RespBean.success();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public RespBean update(@RequestBody ShAreaEntity shArea){
		shAreaService.updateById(shArea);

        return RespBean.success();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public RespBean delete(@RequestBody Integer[] ids){
		shAreaService.removeByIds(Arrays.asList(ids));

        return RespBean.success();
    }

    /**
     * 树列表
     * @return
     */
    @GetMapping("/treeList")
    public RespBean treeList(){
        return shAreaService.getTreeList();
    }



}
